import { ls } from './ls.utils';

export const AuthConstant = {
  AccessToken: 'accessToken',
  RefreshToken: 'refreshToken',
  SilentAccessToken: 'silentAccessToken',
  SilentRefreshToken: 'silentRefreshToken'
};

export function getAccessToken(): string {
  return ls.get(AuthConstant.AccessToken);
}

export function getRefreshToken(): string {
  return ls.get(AuthConstant.RefreshToken);
}

export function setToken(accessToken: string, refreshToken: string) {
  ls.set(AuthConstant.AccessToken, accessToken);
  ls.set(AuthConstant.RefreshToken, refreshToken);
}

export function removeToken() {
  ls.remove(AuthConstant.AccessToken);
  ls.remove(AuthConstant.RefreshToken);
}

export function getSilentAccessToken(): string {
  return ls.get(AuthConstant.SilentAccessToken);
}

export function getSilentRefreshToken(): string {
  return ls.get(AuthConstant.SilentRefreshToken);
}

export function setSilentToken(accessToken: string, refreshToken: string) {
  ls.set(AuthConstant.SilentAccessToken, accessToken);
  ls.set(AuthConstant.SilentRefreshToken, refreshToken);
}

export function removeSilentToken() {
  ls.remove(AuthConstant.SilentAccessToken);
  ls.remove(AuthConstant.SilentRefreshToken);
}
